package com.wootide.cms.common.manager;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

public class MessageUtil {

    static Locale currentLocale = new Locale( "CN");
    static ResourceBundle myResources = ResourceBundle.getBundle("message_resource",
            currentLocale);
    static boolean isInited=false;
    public static void init(){
        if(!isInited){ 
            myResources = ResourceBundle.getBundle("message_resource",
                    currentLocale); 
        } 
    }
    
    public static void init(String[] list){
        if(!isInited){   
            myResources = ResourceBundle.getBundle("message_resource",
                    currentLocale); 
        } 
    }

    //location of {0} in pattern
    public static String getResource(String key) {
        init();
        return myResources.getString(key);
    }
    
    public static String  getResource(String key,Object[] params){
        return MessageFormat.format(getResource(key),params); 
    }

}
